<?php
/*
iSuS - iScripting.net User System
v1.0 made by Panzer
http://www.iScripting.net
Copyright must stay intact
*/


function secure($string) {

$string = strip_tags($string);

$string = htmlspecialchars($string);

$string = trim($string);

$string = stripslashes($string);

$string = mysql_real_escape_string($string);

return $string;

}


function isEmail($email) {


$regex = "/^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/"; 

	if ( preg_match($regex, $email )) {

	return true;

	}

else {

return false;

}

}

function scanThemes(){

   static $alldirs = array();
    $dirs = glob('themes/*', GLOB_ONLYDIR);
    if (count($dirs) > 0) {
        foreach ($dirs as $d) $alldirs[] = $d;
    }
	
	
$rep = str_replace('themes/', '', $alldirs);

foreach ($rep as $rar){

$insertThemes = mysql_query("INSERT INTO `themes` (name) VALUES ('$rar')");


}
}


function deleteThemes(){

$deleteThemes = mysql_query("DELETE FROM `themes` WHERE `active` = ''");

}


function currentTheme(){
	
	$findTheme = mysql_query("SELECT name FROM `themes` WHERE active = '1'");
	while($currentTheme = mysql_fetch_array($findTheme)){
		
		return $currentTheme['name'];
		
	}
	
}

function latestPages($num){

$findPages = mysql_query("SELECT id,author,title FROM `pages` ORDER BY `id` DESC LIMIT 0,$num ")
or die(mysql_error());

while($page = mysql_fetch_array($findPages)){


echo "<a href='index.php?action=viewpage&id=" . $page['id'] . "'>" . $page['title'] . "</a><br />";


}

}







?>